package com.ifreshwing.activity.mine;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.TextInputEditText;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.ifreshwing.activity.base.BaseActivity;
import com.ifreshwing.userpark.R;
import com.ifreshwing.utils.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.ifreshwing.userpark.R.id.titleBar_back;

/**
 * Created by lz on 2017/4/28.
 */

public class ModifyPasswordActivity extends BaseActivity {
    @BindView(titleBar_back)
    ImageView titleBarBack;
    @BindView(R.id.titleBar_text)
    TextView titleBarText;
    @BindView(R.id.et_input_password)
    TextInputEditText etInputPassword;
    @BindView(R.id.et_confirm_password)
    TextInputEditText etConfirmPassword;
    @BindView(R.id.btn_confirm)
    Button btnConfirm;
    @BindView(R.id.coorLayout)
    CoordinatorLayout coorLayout;

    Context context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_modifypwd);
        ButterKnife.bind(this);
        titleBarBack.setVisibility(View.VISIBLE);
        titleBarText.setText("修改密码");
        context = this;
    }

    @OnClick({titleBar_back, R.id.btn_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case titleBar_back:
                finish();
                break;
            case R.id.btn_confirm:
                if (etInputPassword.getText().toString().isEmpty()) {
                    ToastUtil.longToast(context, "请输入原密码");
                    return;
                }
                if (etConfirmPassword.getText().toString().isEmpty()) {
                    ToastUtil.longToast(context, "请输入确认密码");
                    return;
                }
                boolean isOK = etInputPassword.getText().toString().equals(etConfirmPassword.getText().toString());
                if (isOK) {
                    //此处放修改请求
                    ToastUtil.longToast(context, "修改密码成功,请牢记新密码");
                } else {
                    ToastUtil.longToast(context, "两次密码输入不一致");
                    return;
                }
                finish();
                break;
        }
    }
}
